package com.qjs.yonth.webService;

import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Set;

import javax.xml.namespace.QName;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;


public class MyHandle implements SOAPHandler<SOAPMessageContext>{
	
	@Override
	public boolean handleMessage(SOAPMessageContext context) {
		System.out.println("---------MyHandle--------");
        Boolean out = (Boolean)context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); 
        try{
        	SOAPMessage message = context.getMessage();
            OutputStream os=new ByteArrayOutputStream(); 
	        context.getMessage().writeTo(os);
			String mess=os.toString();
			SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			sdf.format(new Date());
			System.out.println(sdf.format(new Date()).toString()+"myhandle:"+out+mess);
        } catch (Exception e) {
        	System.out.println("myhandle，Error:"+e.getMessage());
        }
        return true;
	}

	@Override
	public boolean handleFault(SOAPMessageContext context) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void close(MessageContext context) {
		// TODO Auto-generated method stub
	}

	@Override
	public Set<QName> getHeaders() {
		// TODO Auto-generated method stub
		return null;
	}

	
	
}
